/**
 * @file	cat_controller.h
 * @author	Mitch, David
 * @brief	Header file for cat_controller.c
 */

#ifndef CAT_CONTROLLER_H_
#define CAT_CONTROLLER_H_

/**
 * @brief 	LED initializaton function. Initialize ports PD4 to PD7 to use LEDs.
 */
void init_LED(void);

/**
 * @brief 	Initialize Radio.
 */
void init_radio(void);

/**
 * @brief 	Roomba Driving function. Parameters are velocity and radius.
 */
void roomba_Drive( int16_t velocity, int16_t radius);

/**
 * @brief 	Get bumper status. Return 0 if not activated, otherwise 1.
 */
int get_bumper_status(void);

/**
 * @brief 	Search for n ticks where n x 5 milliseconds = number of milliseconds searching
 */
void search_n_ticks(int n);

/*
 * @brief 	Prepare roomba command packet.
 *
 * @param 	packet a packet to be sent to Roomba
 * @param 	command a command to be sent to Roomba
 * */
void set_roomba_command(radiopacket_t *packet, uint8_t command);

/**
 * @brief 	Radio Send task. Sends a packet asking the mouse for bumper and sensor status.
 */
void radio_tx(void);

/**
 * @brief 	Radio Receive task. Receives reply from mouse of bumper and sensor status.
 * 		  	Game ends if bumper and sensor status are activated, otherwise cat continues chasing mouse.
 */
void radio_rx(void);

/**
 * @brief 	Controller task. This task polls sensor to detect mouse. If it detects the mouse
 * 			it will execute a chasing command. Otherwise, it executes a searching command.
 * 			A chasing command is a roomba movement in the direction of the mouse, executed
 * 			by sending an sci command to the roomba. A searching command is a random
 * 			roomba command executed by using the rand() function.
 */
void search_task(void);

#endif /* CAT_CONTROLLER_H_ */
